from api.base_api import BasePrimeSpApi
from datetime import datetime, timedelta


class AddGeneralProductsInfo(BasePrimeSpApi):
    """
    创建策略
    """
    def __init__(self, name, returnTime_days, planSettleTime_days):
        super().__init__()
        now_dt = datetime.now()
        returnTime = now_dt + timedelta(days=returnTime_days)
        returnTime = int(returnTime.timestamp() * 1000)

        planSettleTime = now_dt + timedelta(days=planSettleTime_days)
        planSettleTime = int(planSettleTime.timestamp() * 1000)
        self.url = f'{self.host}/api/prime/investGeneralProducts/addGeneralProductsInfo'
        self.method = 'post'
        self.json = {
            "name": name,
            "sortNum": 1,
            "investCurrency": "GETH",
            "hookCurrency": "GETH/BUSD",
            "cancelOrderFlag": 2,
            "platformDivisionProportion": 0,
            "optionalFields": [
                "hookCurrency"
            ],
            "profitCalculationType": 1,
            "annualizedProfitRate": "",
            "annualizedProfitRatePersonal": "",
            "annualizedProfitRatePlatform": "",
            "investEndTime": now_dt,
            "returnTime": returnTime,
            "planSettleTime": planSettleTime,
            "lockInterval": 1,
            "settleType": 2,
            "discountRate": "",
            "customerFiledParamRequest": {},
            "id": "",
            "productSubTypeId": "13058313942818",
            "strategyType": 1
        }


if __name__ == '__main__':
    pass
